import requests


def download_video(url, filename):
    # 发送GET请求获取视频内容
    response = requests.get(url, stream=True)

    # 检查请求是否成功
    if response.status_code == 200:
        # 打开文件以二进制写模式写入视频内容
        with open(filename, 'wb') as f:
            for chunk in response.iter_content(1024):
                # 将视频内容分块写入文件
                if chunk:
                    f.write(chunk)
        print(f"视频已成功下载到 {filename}")
    else:
        print(f"请求失败，状态码：{response.status_code}")

    # 视频链接


video_url = 'https://www.vjshi.com/watch/10850403.html'
# 保存的视频文件名
video_filename = 'video.mp4'

# 调用函数下载视频
download_video(video_url, video_filename)
